Removed unused code

Dominik Sander 11 years ago
parent
commit
095c34c696

+ 0 - 39
app/concerns/json_path_options_overwritable.rb

@@ -1,39 +0,0 @@
1
-module JsonPathOptionsOverwritable
2
-  extend ActiveSupport::Concern
3
-  # Using this concern allows providing optional `<attribute>_path` options hash
4
-  # attributes which will then (if not blank) be interpolated using the provided JSONPath.
5
-  #
6
-  # Example options Hash:
7
-  # {
8
-  #   name: 'Huginn',
9
-  #   name_path: '$.name',
10
-  #   title: 'Hello from Huginn'
11
-  #   title_path: ''
12
-  # }
13
-  # Example event payload:
14
-  # {
15
-  #   name: 'dynamic huginn'
16
-  # }
17
-  # calling agent.merge_json_path_options(event) returns the following hash:
18
-  # {
19
-  #   name: 'dynamic huginn'
20
-  #   title: 'Hello from Huginn'
21
-  # }
22
-
23
-  private
24
-  def merge_json_path_options(event)
25
-    options.select { |k, v| options_with_path.include? k}.tap do |merged_options|
26
-      options_with_path.each do |a|
27
-        merged_options[a] = select_option(event, a)
28
-      end
29
-    end
30
-  end
31
-
32
-  def select_option(event, a)
33
-    if options[a.to_s + '_path'].present?
34
-      Utils.value_at(event.payload, options[a.to_s + '_path'])
35
-    else
36
-      options[a]
37
-    end
38
-  end
39
-end

+ 0 - 4
app/models/agent.rb

@@ -121,10 +121,6 @@ class Agent < ActiveRecord::Base
121 121
     end
122 122
   end
123 123
 
124
-  def make_message(payload, message = options[:message])
125
-    message.gsub(/<([^>]+)>/) { Utils.value_at(payload, $1) || "??" }
126
-  end
127
-
128 124
   def trigger_web_request(params, method, format)
129 125
     if respond_to?(:receive_webhook)
130 126
       Rails.logger.warn "DEPRECATED: The .receive_webhook method is deprecated, please switch your Agent to use .receive_web_request."

+ 0 - 31
spec/models/concerns/json_path_options_overwritable.rb

@@ -1,31 +0,0 @@
1
-require 'spec_helper'
2
-
3
-shared_examples_for JsonPathOptionsOverwritable do
4
-  before(:each) do
5
-    @valid_params = described_class.new.default_options
6
-
7
-    @checker = described_class.new(:name => "somename", :options => @valid_params)
8
-    @checker.user = users(:jane)
9
-
10
-    @event = Event.new
11
-    @event.agent = agents(:bob_weather_agent)
12
-    @event.payload = { :room_name => 'test room', :message => 'Looks like its going to rain', username: "Huggin user"}
13
-    @event.save!
14
-  end
15
-
16
-  describe "select_option" do
17
-    it "should use the room_name_path if specified" do
18
-      @checker.options['room_name_path'] = "$.room_name"
19
-      @checker.send(:select_option, @event, :room_name).should == "test room"
20
-    end
21
-
22
-    it "should use the normal option when the path option is blank" do
23
-      @checker.options['room_name'] = 'test'
24
-      @checker.send(:select_option, @event, :room_name).should == "test"
25
-    end
26
-  end
27
-
28
-  it "should merge all options" do
29
-    @checker.send(:merge_json_path_options, @event).symbolize_keys.keys.should == @checker.send(:options_with_path)
30
-  end
31
-end